from symbide import ModuleManager
from symbide.src.execution.executor_python import Executor
import gtk

#matplotlib
from symbide.src.extensions.matplotlib.additionalFunctions import matplot_toxml
#sympy
from symbide.src.extensions.sympy.additionalFunctions import _Sympyplot
#gnuplot
from symbide.src.extensions.gnuplot.additionalFunctions import _Gnuplot
#numpy
from symbide.src.extensions.numpy.additionalFunctions import load_csv
#mathml
from symbide.src.extensions.mathml.additionalFunctions import _to_mathml

from symbide.src.execution.additionalFunctions import _show, _clear

def set(Input):
    assert Input.type=='Python'
    sympyplot = lambda *args, **kwargs: _Sympyplot(Input, *args, **kwargs)
    Input.view.modify_base(gtk.STATE_NORMAL, gtk.gdk.color_parse('#ffffff'))
    Input.global_namespace = {
                'mprint' : lambda x: _to_mathml(Input._objects, x),
                'load_csv': load_csv,
                'Plot' : sympyplot,
                'Sympyplot' : sympyplot,
                'Gnuplot': _Gnuplot,
                'clear' : lambda *args:_clear(Input.local_namespace, *args),
                'show' : lambda x=None:_show(Input._objects, x)
                }
    if ModuleManager.hasModule('gtksourceview'):
        Input.buffer.set_highlight(True)
    Input.executor = Executor()
